﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BoolOperate : StateMachineBehaviour
{
    public float resumeTime;
    public float timer;
    // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        bool w, r, s, f;
        w = animator.GetBool("Walk");
        r = animator.GetBool("Run");
        s = animator.GetBool("Sprint");
        f = animator.GetBool("Falling");

        if (w || r || s || f)
        {
            timer = 0f;
            if (!animator.GetBool("Move")) { animator.SetBool("Move", true); }
        }
        else
        {
            if (animator.GetBool("Move"))
            {
                if (timer < resumeTime)
                {
                    timer += Time.deltaTime;
                }
                else
                {
                    animator.SetBool("Move", false);
                    timer = 0;
                }
            }
        }
    }
}
